home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FAQ.SWG / 0010_BORLAND TOP TEN QA.pas < prev    next >
Pascal/Delphi Source File  |  1993-06-01  |  6KB  |  146 lines

  1. Top Ten Turbo Pascal Technical Support Questions
  2.  
  3.  
  4.   1. How do you read and write a file inside a Turbo Pascal
  5.      program?
  6.  
  7.      Answer: The following example demonstrates how to create,  
  8.      write and read from a text file.
  9.  
  10.      Program FileDemo;
  11.      Var FileVar : Text;
  12.          InString,OutString : String;
  13.      Begin
  14.         OutString := 'Write this to a text file';
  15.         Assign(FileVar,'TEST.TXT'); 
  16.         Rewrite(FileVar);           {Creates a file for writing}
  17.         Writeln(FileVar,OutString); 
  18.         Close(FileVar);
  19.         Assign(FileVar,'TEST.TXT'); 
  20.         Reset(FileVar);      {Opens an existing file for reading}
  21.         ReadLn(FileVar,InString);
  22.         Close(FileVar);
  23.      End.        
  24.                  
  25.  
  26.   2. Where is the GRAPH.TPU file?
  27.  
  28.      Answer: The GRAPH.TPU is archived in the BGI.ARC file. Use
  29.      the UNPACK.COM program to dearchive GRAPH.TPU from the
  30.      BGI.ARC file. For example:  
  31.      
  32.          UNPACK BGI
  33.  
  34.   3. How do you send a program's output to the printer?
  35.  
  36.      Answer: Use the LST file variable declared in the PRINTER
  37.      unit. For example:
  38.  
  39.          Program SendToPrinter;
  40.          Uses Printer;
  41.          Begin
  42.            Writeln(LST,'This will go to the printer.');
  43.          End.
  44.  
  45.   4. Why am I getting a "Unit file format error" when I compile
  46.      my program with the new Turbo Pascal compiler?
  47.  
  48.      Answer: You are using a unit that has been compiled with a
  49.      different Turbo Pascal version. From the main program, use 
  50.      the BUILD option to recompile all dependent units.
  51.  
  52.  
  53.   5. How do you dump graphics to a printer?
  54.  
  55.      Answer: Please see the enclosed Technical Information
  56.      Handouts, #433 and #432, for examples of printing graphics
  57.      on Epson compatible and HP Laser Jet printers.
  58.  
  59.  
  60.   6. How do you communicate with the serial port?
  61.  
  62.      Answer: Modify the AuxInOut unit described in the Reference
  63.      Guide as follows: To read incoming data, use the Reset
  64.      procedure before reading. Also, you should read from a    
  65.      buffer rather than directly from the serial port. 
  66.      Furthermore, the AuxInOut is not an ideal example to use as
  67.      input buffering is not supported;  you should use the    
  68.      enclosed Technical Information Handout #407 routines for
  69.      this purpose. 
  70.  
  71.  
  72.   7. Why doesn't the Exec procedure execute my subprograms?
  73.  
  74.      Answer: Make certain that you use the {$M} directive to set
  75.      the maximum heap size to the lowest possible value.  If this
  76.      is done, check the value of the variable DosError to
  77.      diagnose other problems. What is DosError Returning after
  78.      the call: 
  79.    
  80.      8) Not enough Memory:  User needs to lower MAX Heap 
  81.                             {$M Stack, Min, Max}    
  82.      2) File not found:  User needs to specify the fill Path and
  83.                          extension of the command.  If you're
  84.                          trying to execute a DOS internal
  85.                          command, you need to use COMMAND.COM
  86.                          (see DIR example in manual).
  87.  
  88.  
  89.   8. What do I do about running out of memory during compilation?
  90.  
  91.      Answer: There are a number of solutions to this problem:
  92.  
  93.       1. If Compiler/Destination is set to Memory, set it to Disk
  94.          in the integrated environment.
  95.       2. If Options/Compile/Link buffer in the integrated
  96.          environment is set to Memory, set it to Disk. 
  97.          Alternatively, if you're using 4.0, place a {$L-}
  98.          directive at the beginning of your program.  Use the /L
  99.          option to link to disk in the command-line compiler.
  100.       3. If you are using any memory-resident utilities, such as
  101.          Sidekick and Superkey, remove them from memory.
  102.       4. If you are using TURBO.EXE, try using TPC.EXE instead -
  103.          it takes up less memory.
  104.       5. Turn off any compiler directives which are not
  105.          necessarily needed.  By simply turning off range
  106.          checking {$R-} and software emulation {$E-}, your code
  107.          size will be reduced dramatically.
  108.       6. Move all units, except PRINTER.TPU, out of the TURBO.TPL
  109.          file and into the installed units directory.
  110.       
  111.     If none of these suggestions help, your program or unit may 
  112.     simply be too large to compile in the amount of memory
  113.     available,  and you may have to break in into two or more
  114.     smaller units.  Alternatively, if you're using 5.0+, you
  115.     should consider using overlays.
  116.  
  117.  
  118.   9. How can my program be over-writing memory?
  119.  
  120.      Answer: The most common causes for memory overwrites are:
  121.  
  122.       1. Indexes out of range     (Turn range checking on {$R+}) 
  123.       2. Uninitialized variables  (Write an initialization proc) 
  124.       3. Pointers out of bounds   (Verify that pointers are not 
  125.          pointing outside of the heap space)     
  126.       4. Improper use of FillChar or Move (Be sure to use the
  127.          SizeOf function)     
  128.       5. Illogical operations on strings
  129.    
  130.  
  131.  10. How come I don't get the results that I expect when I
  132.      compare and print real numbers?
  133.  
  134.      Answer: The problem with real numbers in Turbo Pascal is a
  135.      problem with how a real number is stored in binary form. A 
  136.      binary number has no decimal point and thus a real number  
  137.      cannot directly translate into a binary number easily.    
  138.      Calculations must be performed to break a real number down
  139.      into it's binary representation.  As with any calculation  
  140.      that involves division or multiplication, small rounding   
  141.      errors will occur. The problem you are experiencin g is a
  142.      rounding error that occurs during translation from a real
  143.      number into it's binary representation and back. I suggest
  144.      that you round the results of your calculation to the number
  145.      of decimal points that you require to alleviate the problem.
  146.